// pages/view/tabChoose/tabChoose.js
import Toast from '../../../miniprogram_npm/@vant/weapp/toast/toast.js';
const mythis = this
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: 'https://gitee.com/zhang-zhaoming/imgs/raw/master/yidashop/',
    isShow: false,
    showSearch: false,
    activeIndex: 1,
    active: 1,
    statusList: [{
      title: '全部的',
      id: 0,
    }, {
      title: '好吃的',
      id: 1
    }, {
      title: '好玩的',
      id: 2
    }, {
      title: '变美的',
      id: 3
    }, {
      title: '酒店的',
      id: 4
    }, {
      title: '休闲娱乐',
      id: 5,
    }, {
      title: '职业培训',
      id: 6
    }, {
      title: '旅游的',
      id: 7
    }, {
      title: '邑大专属',
      id: 8
    }],
    foodList: [
      {
        imgurl: '/shaoxiancao.png',
        title: '珍珠公|老红糖珍珠奶茶...',
        price: 10.30,
        saleNum: 23
      },
      {
        imgurl: '/shoudaningmengcha.png',
        title: 'Funng Cake小屿烘焙套...',
        price: 22,
        saleNum: 47
      },
      {
        imgurl: '/huoguo.png',
        title: '九记甜品仙气飘飘甜品火...',
        price: 80,
        saleNum: 34
      },
      {
        imgurl: '/tangshui.png',
        title: '测试：小旭糖水奶茶芋圆...',
        price: 10,
        saleNum: 20
      },
      {
        imgurl: '/shoudaningmengcha.png',
        title: '苏阁仙茶汇悦城店优惠...',
        price: 88.88,
        saleNum: 23
      }
    ],
    playList: [
      {
        imgurl: '/haiyiyingyuan.png',
        title: '海逸影院通兑票只要21.9元一张！',
        price: 21.90,
        saleNum: 0
      },
      {
        imgurl: '/huoxinghu.png',
        title: '江门店新会店火星湖影院通兑票只要19.9元！',
        price: 19.90,
        saleNum: 143
      },
      {
        imgurl: '/mishi.png',
        title: '逆次元密室逃脱（沉浸式体验密室主体团票...',
        price: 35,
        saleNum: 27
      },
      {
        imgurl: '/dianyingpiao.png',
        title: 'CGV电影票28.9元通兑票（除IMAX和4D...',
        price: 28.90,
        saleNum: 165
      },
      {
        imgurl: '/jiangmenren.jpg',
        title: '江门人购买【中天新地】19.9元抢香港嘉...',
        price: 19.90,
        saleNum: 203
      },
    ],
    beautyList: [
      {
        imgurl: '/xuanmeiguoji.png',
        title: '【渲美国际】19元抢洗剪吹+...',
        price: 10.30,
        saleNum: 30
      },
      {
        imgurl: '/huiyuechenggongyu.png',
        title: '汇悦城公寓颜匠心造型工...',
        price: 34.90,
        saleNum: 0
      },
      {
        imgurl: '/hexingguangchang.png',
        title: '和兴广场奈斯N+1 HAIR...',
        price: 38,
        saleNum: 22
      },
      {
        imgurl: '/cxzaoxing.png',
        title: 'Cx造型洗剪吹29.9元，烫...',
        price: 10.30,
        saleNum: 14
      },
      {
        imgurl: '/haiyiallin.png',
        title: '海逸城邦ALL in 美发套餐...',
        price: 10.30,
        saleNum: 21
      },
    ],
    barList: [
      {
        imgurl: '/wenquanjiudian.png',
        title: 'Switch电玩游戏来袭！【长提-江门记忆酒店】59元抢SWITCH情侣点...',
        price: 59,
        saleNum: 34
      }
    ],
    leisureList: [
      {
        imgurl: '/wclub.png',
        title: 'W-Club 专享套餐优惠...',
        price: 30,
        saleNum:22
      },
      {
        imgurl: '/wupaijiewu.png',
        title: '【中天新地】19.9抢购原价298元3节课，7大舞种随心选，周末节假...',
        price: 19.90,
        saleNum: 36
      },
      {
        imgurl: '/huoxinghu.png',
        title: '江门店新会店火星湖影院通兑票只要19.9元！',
        price: 19.90,
        saleNum: 143
      }
    ],
    trainList: [
      {
        imgurl: '/wupaijiewu.png',
        title: '舞派街舞，7大舞种随心选，周末节假...',
        price: 9.90,
        saleNum: 20
      },
      {
        imgurl: '/mojingjianshen.png',
        title: '魔晶健身19.9单次体验劵/128元单周体验卡/228双人周卡~',
        price: 19.90,
        saleNum: 0
      },
      {
        imgurl: '/yinyuekecheng.png',
        title: '9.9元，任意音乐课程一对一体验课一节（吉他 钢琴 架子鼓 流行音乐',
        price: 9.90,
        saleNum: 0
      }
    ],
    travelList: [
      {
        imgurl: '/wenquanjiudian.png',
        title: '打卡中国温泉之乡！仅￥99住江门恩平恒大泉都3房1...',
        price: 99,
        saleNum: 0
      }
    ],
    yidaList: [
      {
        imgurl: '/banfudingzhi.png',
        title: 'Sugar邑大班服定制：平...',
        price: 30,
        saleNum: 0
      },
      {
        imgurl: '/zhengjianzhao.png',
        title: '邑大线上证件照：一键美...',
        price: 11,
        saleNum: 1
      },
      {
        imgurl: '/yidaxiaofu.png',
        title: '限量50个邑大校服U盘限量...',
        price: 48.80,
        saleNum: 40
      },
      {
        imgurl: '/yidaxueche.png',
        title: '报价活动：邑大学子学车...',
        price: 2880,
        saleNum: 13
      }
    ],
  },

  onSearch() {
    const that = this
    Toast('功能正在建设中，敬请期待！')
  },

  // 由子盒子改变的tab
  sonChangeChooseList(num) {
    const that = this
    that.setData({
      activeIndex: num
    })
    console.log(mythis)
    console.log('被子组件调用啦', that.data.activeIndex)
  },

  changeChooseList(e) {
    const that = this
    that.setData({
      activeIndex: e.currentTarget.dataset.activeid,
      isShow: false
    })
    const obj = {
      currentTarget: {
        dataset: {
          index: e.currentTarget.dataset.activeid
        }
      }
    }
    this.tabs.swich(obj)
  },

  tabsChange: function (e) {
    console.log(e.detail.index);
  },

  onChange() {
    const that = this
    that.setData({
      isShow: true
    })
  },
  hideChoose() {
    const that = this
    that.setData({
      isShow: false
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options)
    this.setData({
      activeIndex: options.activeIndex,
      showSearch: options.search
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.tabs = this.selectComponent("#tabs")
    const obj = {
      currentTarget: {
        dataset: {
          index: this.data.activeIndex
        }
      }
    }
    this.tabs.swich(obj)
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})